﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lola.DTO;

namespace Lola.Datos.Persistencia
{
    public static class pGalpon
    {
        /// <summary>
        /// Obtiene todos los galpones del sistema
        /// </summary>
        /// <returns></returns>
        public static List<Galpon> getGalpones()
        {
            List<Galpon> res = new List<Galpon>();

            using (SeminarioIEntities contexto = new SeminarioIEntities())
            {
                var query = from gal in contexto.Galpons select gal;
                foreach (Galpon g in query)
                {
                    res.Add(g);
                }
            }

            return res;
        }

        public static int obtenerIdGalpon(string nomgalpon)
        {
            using (SeminarioIEntities contexto = new SeminarioIEntities())
            {
                var idg = from g in contexto.Galpons
                          where g.nomGal.Equals(nomgalpon)
                          select g.idGal;

                return (int)idg.FirstOrDefault();
            }
        }

    }
}
